package com.jz;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.exception.ZuulException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.DEBUG_FILTER_ORDER;
import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.FORM_BODY_WRAPPER_FILTER_ORDER;
import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.PRE_TYPE;

/**
 * Created by Hasee on 2022-02-25.
 */
@Component
@Slf4j
public class PreFilter2 extends ZuulFilter{
    //过滤类型
    @Override
    public String filterType() {
        return PRE_TYPE;
    }

    //过滤等级
    @Override
    public int filterOrder() {
        return FORM_BODY_WRAPPER_FILTER_ORDER;
    }

    //是否开启过滤器
    @Override
    public boolean shouldFilter() {
        return true;
    }

    //要执行的任务
    @Override
    public Object run() throws ZuulException {
        //
        log.info("==========前置过滤器1111111111111111==========");
        System.out.println("==========前置过滤器1111111111111111111==========");
        return "前置过滤器1111111";
    }
}
